#!D:\\Python27\\python
# Filename:backup_ver2.py

import os
import time

source = ['E:\\pytest','F:\\360Downloads']
target_dir = 'F:\\backfile\\'

today = target_dir + time.strftime('%Y%m%d')
now = time.strftime('%H%M%S')

if not os.path.exists(today):
    os.mkdir(today)
    print 'Successfully created dir',today

target = today + os.sep + now +'.rar'
rar_cmd = "rar a %s %s"%(target,' '.join(source))

if os.system(rar_cmd) == 0:
    print 'Successful backup to',target
else:
    print 'Backup FAILED'
